package org.gaaidou.ptarmigan.jdk.jvm;


import java.util.LinkedList;
import java.util.List;

/**
 * GUI
 * Visual VM
 * Plugin: Visual GC
 * doc: <a href="https://docs.oracle.com/en/java/javase/17/gctuning/available-collectors.html#GUID-F215A508-9E58-40B4-90A5-74E29BF3BD3C">...</a>
 */
public final class JvmUtil {

    private static int MAX_DEPTH = 1024 * 1024;

    private static final List<byte[]> strongReference = new LinkedList<>();

    /**
     * -XX:+UseG1GC -Xlog:gc* -Xmx16m -Xms16m
     */
    public static void init() {
        byte[] obj = null;
        for (int index = 0; index < MAX_DEPTH; index++) {
            obj = new byte[1024];
            ThreadUtil.sleep(10);
            if (RandomUtil.rand() > 0.1) {
                strongReference.add(obj);
            }
        }
    }


}
